<template>
  <div class="cell-btn xh-list">
    <search :auto-fixed="false"  v-model="searchText" @on-submit="getResult" placeholder="请输入项目名称查找"></search>
    <group  v-for="(item,index) in getResult" :key="index" class="group-main">
      <cell :link="{path:'/demos/public-msg-proj-detail',query:{PublicMsgGUID:item.PublicMsgGUID}}" >
            <div slot="title" class="list-cell-tilte cell-desc">{{item.MsgTitle}}</div>
            <div slot="inline-desc">
               <span class="cell-desc" >所属公司:&nbsp;{{item.BUName}}</span>
               <span class="cell-desc">发布日期:&nbsp;{{item.PublishDate | formatDate('YYYY-MM-DD') }}</span>
            </div>
      </cell>
    </group>

  </div>
</template>

<script>
import { Search, Tab, TabItem, Group, Cell, XButton } from 'vux'
import {PublicMsgProjService} from '../../service/Services.js'
import _ from 'lodash'

export default {
  name: 'CellBtn',
  components: {
    Search,
    Tab,
    TabItem,
    Group,
    Cell,
    XButton
  },
  data () {
    return {
      searchText: '',
      pageData: {}
    }
  },
  methods: {
    loadData () {
      this.$vux.loading.show({
        text: '加载中...'
      })
      PublicMsgProjService.getPublicMsgProj().then((res) => {
        this.$vux.loading.hide()
        this.pageData = res.Data
      }).catch((res) => {
        this.$vux.toast.show({
          text: '请求失败,请联系管理员',
          type: 'cancel',
          width: '180px'
        })
        console.log(res)
      })
    }
  },
  computed: {
    getResult () {
      return _.filter(this.pageData, item => { return item.MsgTitle.indexOf(this.searchText) !== -1 })
    }
  },
  created () {
    this.loadData()
  }
}
</script>

<style scoped lang="less">
@import '../../assets/less/list.less';
</style>
